<?php require_once 'include.php';
$address=getAllAddress();
checkUserLogined();
?>
<html>
	<head>
		<meta charset="utf-8">
		<title>个人中心</title>
		<meta name="keywords" content="">
		<meta name="description" content="">
		<link rel="stylesheet" href="userindex/css/safe/ms-style.min.css" />
		<link rel="stylesheet" href="userindex/css/safe/personal_member.min.css" />
		<link rel="stylesheet" href="userindex/css/safe/Snaddress.min.css" />
		<script type="text/javascript" src="js/goodsdetail.js"></script>
		<script src="js/jquery-1.6.js" type="text/javascript"></script>
	</head>
<body class="grey">
<?php include 'header.php';?>
<div id="" class="ng-top-banner"></div>
<div id="ms-center" class="personal-member">
			<div class="cont">
				<div class="cont-side">
					<div class="side-neck" style="margin-top: 20px;">
						<i></i>
					</div>
					<div class="ms-side" style="margin-top: 20px;">
						<article class="side-menu side-menu-off">
							<dl class="side-menu-tree" style="padding-left: 50px;">
								<dt><a href="userHome.php"><img src="userindex/img/user_icon2.png"  style="margin-right: 10px;margin-left: -20px;"/>
									个人中心</a></dt>
								<dd><a href="userModify.php">修改资料</a></dd>
								<dd><a href="">收货地址</a></dd>
								<dt><img src="userindex/img/shoppingcart.png"  style="margin-right: 10px;margin-left: -20px;"/>我的购物车</dt>
								<dt><img src="userindex/img/file.png"  style="margin-right: 10px;margin-left: -20px;"/>订单管理</dt>
								<dd><a href="myorders.php">我的订单</a></dd>
							</dl>
							<a ison="on" class="switch-side-menu icon-up-side"><i></i></a>
						</article>
					</div>
				</div>
				<div class="cont-main">
					<div class="main-wrap mt15">
						<h3>
	                        <strong>个人信息</strong>
	                    </h3>

		<h3 class="shopping_tit">收货地址列表
			<a href="javascript:showAddress('addNewAddress')" class="backCar">添加新的收货地址</a>
		</h3>
		<div class="shopping_cont pb_10">
			<div class="cart_inner">
				<div class="cart_head clearfix">
					<div class="cart_item t_name" style="width:55%">详细地址</div>
					<div class="cart_item t_price_cart" style="width:15%">收货人</div>
					<div class="cart_item t_return_cart" style="width:15%">手机号</div>
					<div class="cart_item t_operator_cart" style="width:12%">操作</div>
				</div>
				<?php foreach($address as $addr):?>
				<div class="cart_cont clearfix" id="addressInfo-<?php echo $addr['id']?>">
					<div class="cart_item t_name"  style="width:55%">
						<p class="cart_link" style="margin-bottom: 0px;" />
						<span id="address-<?php echo $addr['id']?>"><?php echo $addr['addressDetail']?></span></p>
					</div>
					<div class="cart_item t_price_cart"  style="width:15%">
						<span id="consignee-<?php echo $addr['id']?>"><?php echo $addr['consignee'];?></span></div>
					<div class="cart_item t_return_cart"  style="width:15%">
						<span id="phone-<?php echo $addr['id']?>"><?php echo $addr['Phone'] ?></span></div>
					<div class="cart_item t_operator_cart"  style="width:12%">
						<a href="javascript:changeAddress(<?php echo $addr['id']?>);">修改</a>
						<a href="javascript:deleteAddress(<?php echo $addr['id']?>);">删除</a>
					</div>
				</div>
				<?php endforeach;?>
			</div>
		</div>
		<script type="text/javascript">
			function showAddress(what){
				var tabsContent = getClass('div',what); 
				tabsContent[0].className = what; 
				}
			function changeAddress(addressId){
				showAddress('changeAddress'); 
				document.getElementById('addressId').value=addressId;
				document.getElementById('consignee').value=document.getElementById('consignee-'+addressId).innerText;
				document.getElementById('phone').value=document.getElementById('phone-'+addressId).innerText;
				document.getElementById('addressDetail').value=document.getElementById('address-'+addressId).innerText;
			}
			function deleteAddress(addressId){
				var url="doAction.php?act=deleteAddress";
				var data={"addressId":addressId};
				var success=function(response){
						if(response.errno==0){
							$("#addressInfo-"+addressId).remove();
							alert("删除成功");
						}else{
							alert("删除失败");
						}
					}
				$.get(url,data,success,"json");
			}
		</script>
		<div class="addNewAddress hide">
			<h3><strong>添加收货信息</strong></h3>
				<div class="form-list tab-switch personal-wrap-show">
					<form method="post" enctype="multipart/form-data" action="doAction.php?act=addNewAddress" id="form1">
						<div class="control-group clearfix">
							<label class="control-label"><em>*&nbsp;</em>收货人：</label>
							<div class="controls">
								<input  type="text" class="text" maxlength="12"  value="" name="consignee"  required="required">
							</div>
						</div>
						<div class="control-group clearfix">
							<label class="control-label"><em>*&nbsp;</em>手机号：</label>
								<div class="controls lh26">
									<input  type="text" class="text" maxlength="12"  value="" name="phone"  required="required">
								</div>
							</div>
						<div class="control-group clearfix priority-high">
							<label class="control-label"><em>*&nbsp;</em>详细地址：</label>
							<div class="controls">
								<p class="adress-detail">
									<input type="text" class="text" maxlength="100"  value="高新区" name="addressDetail"  required="required">
									<span class="tips-words"></span>
								</p>		
								<div id="" class="error-place ml0"></div>
							</div>
						</div>
						<div class="control-group clearfix priority-low">
							<label class="control-label">&nbsp;</label>
							<div style="float:left;">
								<input type="submit"  class="ms-stand-btn1"  value="提交" />
							</div>
							<div id="" class="error-place"></div>
							<div class="error-place mt29"></div>
					</div>
					</form>
					
				</div>
			</div>
			<div class="changeAddress hide">
				<h3>
	           		<strong>修改收货信息</strong>
	           	</h3>
				<div class="form-list tab-switch personal-wrap-show">
					<form method="post" enctype="multipart/form-data" action="doAction.php?act=changeAddress" id="form2">
						
						<div class="control-group clearfix">
							<label class="control-label"><em>*&nbsp;</em>收货人：</label>
							<div class="controls">
								<input type="hidden" class="text" maxlength="10" name="addressId" id="addressId" value="">
								<input  type="text" class="text" maxlength="12"  value="" name="consignee"  id="consignee" required="required">
							</div>
						</div>
						<div class="control-group clearfix">
							<label class="control-label"><em>*&nbsp;</em>手机号：</label>
								<div class="controls lh26">
									<input  type="text" class="text" maxlength="12"  value="" name="phone"  id="phone" required="required">
								</div>
							</div>
						<div class="control-group clearfix priority-high">
							<label class="control-label"><em>*&nbsp;</em>详细地址：</label>
							<div class="controls">
								<p class="adress-detail">
									<input type="text" class="text" maxlength="100"  value="" name="addressDetail"  id="addressDetail" required="required">
									<span class="tips-words"></span>
								</p>		
								<div id="" class="error-place ml0"></div>
							</div>
						</div>
						<div class="control-group clearfix priority-low">
							<label class="control-label">&nbsp;</label>
							<div style="float:left;">
								<input type="submit"  class="ms-stand-btn1"  value="提交" />
							</div>
							<div id="" class="error-place"></div>
							<div class="error-place mt29"></div>
					</div>
					</form>
					
				</div>
			</div>
					
				</div>
			</div>
				
			</div>
		</div>
		<div class="clear"></div>
		<div class="ng-footer" style="height: 130px;margin-top: 0;">
			<textarea class="footer-dom" id="footer-dom-02">
			</textarea>
			<div class="ng-fix-bar"></div>
		</div>
		<?php include 'footer.php';?>
	</body>
